package com.smartalarmclock.UI.Games;

import com.smartalarmclock.UI.R;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RadioButton;
import android.widget.RadioGroup;

public class MainGamesActivity extends Activity {
	
	private RadioGroup radioGameGroup;
	private RadioButton radioGameButton;
	private Button buttonStartGame;


	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.games_main);
		
		addListenerOnButton();
	}
	
	public void addListenerOnButton() {
		
		radioGameGroup = (RadioGroup) findViewById(R.id.radioGame);
		buttonStartGame = (Button) findViewById(R.id.buttonStart);
		
		buttonStartGame.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {			
				
				String userChoice;
		        // get selected radio button from radioGroup
				int selectedId = radioGameGroup.getCheckedRadioButtonId();
				
				// find the radiobutton by returned id
		        radioGameButton = (RadioButton) findViewById(selectedId);
		        
		        userChoice = radioGameButton.getText().toString();
		        
        		if("Play Ringtone".equals(userChoice))
        		{
        			Intent profileActivity = new Intent(MainGamesActivity.this,PlayRingtoneActivity.class);     
        			startActivity(profileActivity);
        		}
        		else if("Math Exercise".equals(userChoice))
        		{
        			Intent vipActivity = new Intent(MainGamesActivity.this, MathExerciseActivity.class);     
        			startActivity(vipActivity);
        		}
        		else if("Text Input".equals(userChoice))
        		{
        			Intent groupActivity = new Intent(MainGamesActivity.this,TextInputActivity.class);     
        			startActivity(groupActivity);
        		}
			}
			});
		}
}
